﻿using HamcoWcs.Contract.ContractCommon;
using HamcoWcs.Contract.ContractMainTask.IMainTaskParsers;
using HamcoWcs.Entitys.MainTasks;
using HamcoWcs.Models.Common.Enums;
using HamcoWcs.Models.EdgeInfos;
using HamcoWcs.Service.Common;

namespace HamcoWcs.Service.MainTasks.SubTaskParsers
{
    [AutoInject(typeof(ISubTaskParser), InjectType.Scope)]
    public class SubTaskParser_SrmMoveTask : SubTaskParserBase
    {
        public override EnumSubTaskType SubTaskType => EnumSubTaskType.SrmMoveTask;

        public SubTaskParser_SrmMoveTask(ILocationService locationService) : base(locationService)
        {
        }

        public override void Deal(MainTask mainTask, EdgeInfoDto edge)
        {
            var loc = _locationService.GetLocationByWcsName(mainTask.SrcPosition);
            loc.LocStatus = (int)EnumLocStatus.Out;

            var subTask = CreateNewSubTask(mainTask, mainTask.SrcPosition, mainTask.DesPosition, edge.ExcutePlc);
            mainTask.SubTasks.Add(subTask);
        }
    }
}
